package com.chainofresponsibility.pattern.service.handler;

import com.chainofresponsibility.pattern.domain.AuditInfo;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author cc
 * @classname AuditHandler
 * @description 链路抽象类
 * @date 2022/3/29 15:25
 */
public abstract class AuditHandler {

    protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 时间格式化

    protected String levelUserId; // 级别⼈员ID
    protected String levelUserName; // 级别⼈员姓名
    private AuditHandler next; // 责任链

    public AuditHandler(String levelUserId, String levelUserName) {
        this.levelUserId = levelUserId;
        this.levelUserName = levelUserName;
    }

    //通过 next ⽅式获取下⼀个链路需要处理的节点
    public AuditHandler next() {
        return next;
    }

    public AuditHandler appendNext(AuditHandler next) {
        this.next = next;
        return this;
    }

    //是每⼀个实现者必须实现的类，不同的审核级别处理不同的业务
    public abstract AuditInfo doAudit(String uid, String orderId, Date auditDate);
}
